package com.kzj.laimeimei.recyclerCard.cardView;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.kzj.laimeimei.R;
import com.kzj.laimeimei.recyclerCard.basic.CardItemView;
import com.kzj.laimeimei.recyclerCard.card.other.SelectAddressCard;

/**
 * Created by xyg on 2015/10/26.
 */
public class SelectAddressCardView extends CardItemView<SelectAddressCard> {

    private Context context;
    private TextView textView_address;
    private ImageView imageView_select;

    public SelectAddressCardView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public SelectAddressCardView(Context context) {
        super(context);
        this.context = context;
    }

    public SelectAddressCardView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }

    @Override
    public void build(final SelectAddressCard card) {
        super.build(card);
        textView_address = (TextView) findViewById(R.id.textView_address);
        imageView_select = (ImageView) findViewById(R.id.imageView_select);
        if (card.isSelect()) {
            imageView_select.setImageResource(R.drawable.icon_correct);
        } else {
            imageView_select.setImageBitmap(null);
        }
        textView_address.setText(card.getAddressBean().getAddress());
        this.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                imageView_select.setImageResource(R.drawable.icon_correct);
                card.getOnNormalButtonPressedListener().onButtonPressedListener(v, card);
            }
        });
    }
}
